package com.shunhe.storage.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.shunhe.storage.R;
import com.shunhe.storage.dao.model.Goods;
import com.shunhe.storage.support.view.SwipeMenuView;

// 侧滑的货品列表
public class SwipeGoodsListAdapter extends ListBaseAdapter<Goods> {
    public SwipeGoodsListAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_goods_list_swipe;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        SwipeMenuView sw_item = holder.getView(R.id.sw_item);
        TextView tv_del = holder.getView(R.id.tv_del);

        Goods goods = mDataList.get(position);

        tv_del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != onSwipeListener) {
                    onSwipeListener.onDel(goods, position);
                }
            }
        });

    }

    OnSwipeListener onSwipeListener;

    public void setOnSwipeListener(OnSwipeListener onSwipeListener) {
        this.onSwipeListener = onSwipeListener;
    }

    public interface OnSwipeListener {
        void onDel(Object obj, int index);
    }
}